import wepy from 'wepy'

export default class extends wepy.mixin {
  data = {
    swiperList: [],
    catesItemsList: [],
    floorData: []
  }

  onLoad() {
    this.getSwiperList()
    this.getCatesItemsList()
    this.getFloorData()
  }

  methods = {
    goGoodsList(url) {
      wepy.navigateTo({
        url
      })
    }
  }

  async getSwiperList() {
    const { data: res } = await wepy.get('/home/swiperdata')
    if (res.meta.status !== 200) {
      return wepy.baseToast()
    }
    this.swiperList = res.message
    this.$apply()
  }

  async getCatesItemsList() {
    const { data: res } = await wepy.get('/home/catitems')
    if (res.meta.status !== 200) {
      return wepy.baseToast()
    }
    this.catesItemsList = res.message
    this.$apply()
  }

  async getFloorData() {
    const { data: res } = await wepy.get('/home/floordata')
    if (res.meta.status !== 200) {
      return wepy.baseToast()
    }
    this.floorData = res.message
    this.$apply()
  }
}
